﻿
namespace Validator
{
    public class StringLengthValidator : BaseValidator
    {
        public StringLengthValidator(string message, int _maxLength, string _friendlyName = "")
            : base(message, _friendlyName)
        {
            this.MaxLength = _maxLength;
        }

        private int MaxLength { get; set; }
        public override bool IsValid(object item, bool ValidateEmptyString = false)
        {
            if (!string.IsNullOrEmpty((string)item) && ((string)item).Length > MaxLength)
                return false;
            else
                return true;
        }
    }
}
